<?php

	// TITLE: Home_owner_status_change AUTO MODEL
	// FILE: scaffolding/model/home_owner_status_change.php
	// AUTHOR: AUTOGEN
	// CREATED: 2015/04/20 07:49:57
	// DESCRIPTION: 
	// REQUIREMENTS: 

	$createHomeOwnerStatusChange = function($con, $homeOwnerStatusChange) {
		$sql = 'INSERT INTO home_owner_status_change (homeowner_id, home_owner_status_id, who_changed, when_changed, who_authorized, when_authorized) VALUES (';
		$sql .= $home_owner_status_change->getHomeownerId() . ', ';
		$sql .= $home_owner_status_change->getHomeOwnerStatusId() . ', ';
		$sql .= $home_owner_status_change->getWhoChanged() . ', ';
		$sql .= $home_owner_status_change->getWhenChanged() . ', ';
		$sql .= $home_owner_status_change->getWhoAuthorized() . ', ';
		$sql .= $home_owner_status_change->getWhenAuthorized() . ')';
		$sql .= ')';
		$result = mysqli_query($con, $sql);
		$id = ($result) ? mysqli_insert_id($con) : $result;
		mysqli_close($con);
		return $id;
	};

	$readHomeOwnerStatusChange = function($con, $id) {
		$sql = 'SELECT * FROM home_owner_status_change WHERE id = ' . $id;
		$results = mysqli_query($con, $sql);
		mysqli_close($con);
		if ($results) {
			$result = mysqli_fetch_array($results);
			$homeOwnerStatusChange = new HomeOwnerStatusChange();
			$homeOwnerStatusChange->setHomeownerId($dbio->select($readHomeowner(result[0])));
			$homeOwnerStatusChange->setHomeOwnerStatusId($dbio->select($readHomeOwnerStatus(result[1])));
			$homeOwnerStatusChange->setWhoChanged(result[2]);
			$homeOwnerStatusChange->setWhenChanged(result[3]);
			$homeOwnerStatusChange->setWhoAuthorized(result[4]);
			$homeOwnerStatusChange->setWhenAuthorized(result[5]);
		} else {
			$homeOwnerStatusChange = false;
		}
		return $homeOwnerStatusChange;
	};

	$updateHomeOwnerStatusChange = function($con, $homeOwnerStatusChange) {
		$sql = 'UPDATE home_owner_status_change SET ';
		$sql .= 'homeowner_id = ' . $home_owner_status_change->getHomeownerId() . ', ';
		$sql .= 'home_owner_status_id = ' . $home_owner_status_change->getHomeOwnerStatusId() . ', ';
		$sql .= 'who_changed = ' . $home_owner_status_change->getWhoChanged() . ', ';
		$sql .= 'when_changed = ' . $home_owner_status_change->getWhenChanged() . ', ';
		$sql .= 'who_authorized = ' . $home_owner_status_change->getWhoAuthorized() . ', ';
		$sql .= 'when_authorized = ' . $home_owner_status_change->getWhenAuthorized() ;
		$sql .= 'WHERE id = ' . id;
		$result = mysqli_query($con, $sql);
		mysqli_close($con);
		return $result;
	};

	$deleteHomeOwnerStatusChange = function($con, $id) {
		$sql = 'DELETE FROM home_owner_status_change WHERE homeowner_id = ' . $id;
		$result = mysqli_query($con, $sql);
		mysqli_close($con);
		return $result;
	};

	$listHomeOwnerStatusChange = function($con) {
		$sql = 'SELECT * FROM home_owner_status_change';
		$results = mysqli_query($con, $sql);
		mysqli_close($con);
		if ($results) {
			$homeOwnerStatusChanges = array();
			while ($result = mysqli_fetch_array($results)) {
				$homeOwnerStatusChange = new HomeOwnerStatusChange();
				$homeOwnerStatusChange->setHomeownerId($dbio->select($readHomeowner(result[0])));
				$homeOwnerStatusChange->setHomeOwnerStatusId($dbio->select($readHomeOwnerStatus(result[1])));
				$homeOwnerStatusChange->setWhoChanged(result[2]);
				$homeOwnerStatusChange->setWhenChanged(result[3]);
				$homeOwnerStatusChange->setWhoAuthorized(result[4]);
				$homeOwnerStatusChange->setWhenAuthorized(result[5]);
				$homeOwnerStatusChanges[] = homeOwnerStatusChange;
			}// end while
		} else {
			$homeOwnerStatusChanges = false;
		}
		return $homeOwnerStatusChanges;
	};

